import React, { lazy, Suspense } from "react";
import { Link, Switch, Route } from "react-router-dom";

const Home1 = lazy(() => import("./Home1"));
const Home2 = lazy(() => import("./Home2"));

console.log("首页加载");

const Home = () => {
  return (
    <>
      <div>这是home页面</div>
      <ul>
        <li>
          <Link to="/home/home1">首页1</Link>
        </li>
        <li>
          <Link to="/home/home2">首页2</Link>
        </li>
      </ul>

      <hr />

      <Suspense fallback={<div>122222222</div>}>
        <Switch>
          <Route path="/home/home1">
            <Home1 />
          </Route>
          <Route path="/home/home2">
            <Home2 />
          </Route>
        </Switch>
      </Suspense>
    </>
  );
};

export default Home;
